<template>
    <el-tabs type="border-card" class="edittabform">
        <el-tab-pane label="数据">
            <el-row type="flex" class="editformitem" align="middle">
                <el-col :span="8" class="editlabel">
                    <span>数据表格</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-select v-model="obj.tableData.tableId" filterable clearable placeholder="请选择数据" size="mini"
                        @change="tableSelectChange">
                        <el-option v-for="item in dataTableList" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem" align="middle">
                <el-col :span="8" class="editlabel">
                    <span>数值</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-select v-model="obj.tableData.valueId" filterable clearable placeholder="请选择数据" size="mini">
                        <el-option v-for="item in columnData" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem" align="middle">
                <el-col :span="8" class="editlabel">
                    <span>日期</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-select v-model="obj.tableData.dateId" filterable clearable placeholder="请选择数据" size="mini">
                        <el-option v-for="item in columnData" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem">
                <el-col :span="8" class="editlabel">
                    <span>时间点</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <el-time-select v-model="obj.tableData.startTime" style="width:85px;margin-right:10px;" :picker-options="{
                        start: '00:00',
                        step: '01:00',
                        end: '24:00'
                    }" />
                    <el-time-select v-model="obj.tableData.endTime" style="width:85px;margin-right:10px;" :picker-options="{
                        start: '00:00',
                        step: '01:00',
                        end: '24:00'
                    }">
                    </el-time-select>
                    <el-color-picker v-model="obj.tableData.endColor" size="small" show-alpha :predefine="predefineColors"
                        popper-class="mycolorview" @active-change="setColorChange(obj.tableData, 'endColor', $event)" />
                </el-col>
            </el-row>
            <el-row type="flex" class="editformitem" align="middle" v-for="(item, index) in obj.tableData.status"
                :key="'status' + index">
                <el-col :span="8" class="editlabel">
                    <span>状态{{ index + 1 }}</span>
                </el-col>
                <el-col :span="16" class="editcontent sldyinput">
                    <input type="number" v-model="item.value1" style="width: 70px; line-height: 20px;margin-right:10px;" />
                    <input type="number" v-model="item.value2" style="width: 70px; line-height: 20px;margin-right:10px;" />
                    <el-color-picker popper-class="mycolorview" v-model="item.color" size="small" show-alpha
                        :predefine="predefineColors"
                        @active-change="setColorChange(obj.tableData.status[index], 'color', $event)" />
                    <i class="el-icon-error" v-if="index > 0" @click="deleteDataYinfo(obj.tableData.status, index)"></i>
                </el-col>
            </el-row>

            <div class="addybtn" @click="addStatusinfo(obj.tableData.status)" style="margin-right:0px;">
                + 添加状态
            </div>
            <el-row type="flex" class="editformitem">
                <el-col :span="8" class="editlabel">
                    <span>数字字体</span>
                </el-col>
                <el-col :span="16" class="editcontent">
                    <input v-model.number="obj.tableData.dateTimeSize" class="miniinput" type="number" />
                    <el-color-picker v-model="obj.tableData.dateTimeColor" size="small" show-alpha
                        :predefine="predefineColors" popper-class="mycolorview"
                        @active-change="setColorChange(obj.tableData, 'dateTimeColor', $event)" />
                    <div class="fontstylev">
                        <div :class="['fontitem', { 'active': obj.tableData.dateTimeWeight == 'bold' }]"
                            @click="setFontStyle('fontWeight', obj.tableData, 'dateTimeWeight')"><i
                                class="iconfont icon-zitijiacu"></i>
                        </div>
                        <div :class="['fontitem', { 'active': obj.tableData.dateTimeStyle == 'italic' }]"
                            @click="setFontStyle('fontStyle', obj.tableData, 'dateTimeStyle')"><i
                                class="iconfont icon-zitixieti"></i>
                        </div>
                    </div>
                </el-col>
            </el-row>
            <title-form :predefineColors="predefineColors" :obj="obj" :setColorChange="setColorChange"
                :setFontStyle="setFontStyle" :isShowCheckout="false"></title-form>
        </el-tab-pane>
        <el-tab-pane label="布局">
            <box-form :predefineColors="predefineColors" :obj="obj" :setColorChange="setColorChange"></box-form>
        </el-tab-pane>
    </el-tabs>
</template>

<script>
export default {
    name: "TimeSpeedForm",
    props: {
        predefineColors: Array,
        obj: Object,
        dataTableList: Array,
        columnData: Array,
        tableSelectChange: Function,
        deleteDataYinfo: Function,
        setFontStyle: Function,
        setColorChange: Function,
    },
    model: {
        prop: "obj",
        event: "change",
    },
    components: {
        TitleForm: () => import('../mixin/TitleForm.vue'),
        BoxForm: () => import('../mixin/BoxForm.vue'),
    },
    methods: {
        addStatusinfo(item) {
            item.push({ value1: "", value2: "", color: this.predefineColors[item.length] });
        },
    }
}
</script>
